import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:flutter_oa/route/routes.dart';
import 'package:flutter_oa/utils/const.dart';

class Me extends StatefulWidget {
  @override
  _MeState createState() => _MeState();
}

class _MeState extends State<Me> {
  var _image;

  _intentImagePicker(String type) async {
    String route = '${Routes.myimagepicker}?type=$type';
    _image = await Routes.router.navigateTo(context, route,
        replace: false, transition: TransitionType.fadeIn);
  }

  Widget _ImageView(imgPath) {
    if (imgPath == null) {
      return Center(
        child: Icon(
          Icons.image,
          color: Colors.grey,
          size: 60,
        ),
      );
    } else {
      return Image.file(
        imgPath,
        width: 60,
        height: 60,
      );
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title: Text(
          '个人信息',
          style: TextStyle(color: Colors.black),
        ),
        backgroundColor: Colors.grey[200],
        automaticallyImplyLeading: false,
//        leading: IconButton(
//            icon: Icon(
//              Icons.arrow_back_ios,
//              color: Colors.black,
//            ),
//            onPressed: () {
//              Navigator.pop(context);
//            }),
//        elevation: 0.0,
      ),
      body: Container(
        color: Colors.grey[200],
        child: Column(
          children: <Widget>[
            GestureDetector(
              onTap: () {
                showModalBottomSheet(
                    context: context,
                    builder: (BuildContext context) {
                      return Column(
                        mainAxisSize: MainAxisSize.min,
                        children: <Widget>[
                          ListTile(
                            title: Text('相机'),
                            onTap: () {
                              Navigator.pop(context);
                              _intentImagePicker(Const.Camera);
                            },
                          ),
                          ListTile(
                            title: Text('相册'),
                            onTap: () {
                              Navigator.pop(context);
                              _intentImagePicker(Const.Picture);
                            },
                          )
                        ],
                      );
                    });
              },
              child: Container(
                padding: EdgeInsets.fromLTRB(15, 0, 10, 0),
                color: Colors.white,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: <Widget>[
                    Text(
                      '头像',
                      style: TextStyle(color: Colors.black, fontSize: 16),
                    ),
                    Row(
                      children: <Widget>[
                        Hero(tag: 'hero', child: _ImageView(_image)),
                        Icon(
                          Icons.arrow_right,
                          color: Colors.black,
                        )
                      ],
                    ),
                  ],
                ),
              ),
            ),
            SizedBox(
              height: 10,
            ),
            Container(
              padding: EdgeInsets.fromLTRB(15, 0, 15, 0),
              color: Colors.white,
              height: 50,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  Text(
                    '用户名',
                    style: TextStyle(color: Colors.black, fontSize: 16),
                  ),
                  Text(
                    '白洁',
                    style: TextStyle(color: Colors.grey[400], fontSize: 14),
                  ),
                ],
              ),
            ),
            SizedBox(
              height: 1,
            ),
            Container(
              padding: EdgeInsets.fromLTRB(15, 0, 15, 0),
              color: Colors.white,
              height: 50,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  Text(
                    '部门职位',
                    style: TextStyle(color: Colors.black, fontSize: 16),
                  ),
                  Text(
                    '教师',
                    style: TextStyle(color: Colors.grey[400], fontSize: 14),
                  ),
                ],
              ),
            ),
            SizedBox(
              height: 10,
            ),
            Container(
              padding: EdgeInsets.fromLTRB(15, 0, 15, 0),
              color: Colors.white,
              height: 50,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  Text(
                    '帐号',
                    style: TextStyle(color: Colors.black, fontSize: 16),
                  ),
                  Text(
                    '13423443344',
                    style: TextStyle(color: Colors.grey[400], fontSize: 14),
                  ),
                ],
              ),
            ),
            SizedBox(
              height: 1,
            ),
            Container(
              padding: EdgeInsets.fromLTRB(15, 0, 10, 0),
              color: Colors.white,
              height: 50,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  Text(
                    '手机号',
                    style: TextStyle(color: Colors.black, fontSize: 16),
                  ),
                  Row(
                    children: <Widget>[
                      Text(
                        '13455778899',
                        style: TextStyle(color: Colors.grey[400], fontSize: 14),
                      ),
                      Icon(
                        Icons.keyboard_arrow_right,
                        color: Colors.grey,
                      )
                    ],
                  ),
                ],
              ),
            ),
            SizedBox(
              height: 1,
            ),
            Container(
              padding: EdgeInsets.fromLTRB(15, 0, 10, 0),
              color: Colors.white,
              height: 50,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  Text(
                    '修改密码',
                    style: TextStyle(color: Colors.black, fontSize: 16),
                  ),
                  Icon(
                    Icons.keyboard_arrow_right,
                    color: Colors.grey,
                  )
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
